<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1"><title id="pg137116">reindexdb</title><body><p id="client_util_desc">Rebuilds indexes in a database.</p><section id="section2"><title>Synopsis</title><codeblock id="client_util_synopsis">reindexdb [&lt;connection-option> ...] [--table | -t &lt;table> ] 
        [--index | -i &lt;index> ] [&lt;dbname>]

reindexdb [&lt;connection-option> ...] --all | -a

reindexdb [&lt;connection-option> ...] --system | -s [&lt;dbname>]

reindexdb -? | --help

reindexdb -V | --version</codeblock></section><section id="section3"><title>Description</title><p><codeph>reindexdb</codeph> is a utility for rebuilding indexes in Greenplum Database.</p>
<p> <codeph>reindexdb</codeph> is a wrapper around the SQL command <codeph>REINDEX</codeph>. There is no effective difference between reindexing databases via this utility and via other methods for accessing the server. </p></section>
<section id="section4"><title>Options</title><parml><plentry><pt>-a | --all</pt><pd>Reindex all databases.</pd></plentry><plentry><pt>[-d] <varname>dbname</varname> | [--dbname=]<varname>dbname</varname></pt><pd>Specifies the name of the database to be reindexed. If this is not specified and
              <codeph>-all</codeph> is not used, the database name is read from the environment
            variable <codeph>PGDATABASE</codeph>. If that is not set, the user name specified for
            the connection is used.</pd></plentry><plentry><pt>-e | --echo</pt><pd>Echo the commands that <codeph>reindexdb</codeph> generates and sends
to the server.</pd></plentry><plentry><pt>-i <varname>index</varname> | --index=<varname>index</varname></pt><pd>Recreate index only.</pd></plentry><plentry><pt>-q | --quiet</pt><pd>Do not display a response.</pd></plentry><plentry><pt>-s | --system</pt><pd>Reindex system catalogs.</pd></plentry><plentry><pt>-t <varname>table</varname> | --table=<varname>table</varname></pt><pd>Reindex table only. Multiple tables can be reindexed by writing multiple <codeph>-t</codeph> switches.</pd></plentry>
        <plentry>
          <pt>-V | --version</pt>
          <pd>Print the <codeph>reindexdb</codeph> version and exit.</pd>
        </plentry>
        <plentry>
          <pt>-? | --help</pt>
          <pd>Show help about <codeph>reindexdb</codeph> command line arguments, and exit.</pd>
        </plentry></parml><sectiondiv id="section5"><b>Connection Options</b><parml><plentry><pt>-h <varname>host</varname> | --host=<varname>host</varname></pt><pd>Specifies the host name of the machine on which the Greenplum
              master database server is running. If not specified, reads from the environment
              variable <codeph>PGHOST</codeph> or defaults to localhost.</pd></plentry><plentry><pt>-p <varname>port</varname> | --port=<varname>port</varname></pt><pd>Specifies the TCP port on which the Greenplum master database
              server is listening for connections. If not specified, reads from the environment
              variable <codeph>PGPORT</codeph> or defaults to 5432.</pd></plentry><plentry><pt>-U <varname>username</varname> | --username=<varname>username</varname></pt><pd>The database role name to connect as. If not specified, reads from
the environment variable <codeph>PGUSER</codeph> or defaults to the current
system user name.</pd></plentry><plentry><pt>-w | --no-password</pt><pd>Never issue a password prompt. If the server requires password authentication
and a password is not available by other means such as a <codeph>.pgpass</codeph>
file, the connection attempt will fail. This option can be useful in
batch jobs and scripts where no user is present to enter a password.</pd></plentry><plentry><pt>-W | --password</pt><pd>Force a password prompt.</pd></plentry>
          <plentry>
            <pt>--maintenance-db=<varname>dbname</varname></pt>
            <pd>Specifies the name of the database to connect to discover what other databases
              should be reindexed. If not specified, the <codeph>postgres</codeph> database will be
              used, and if that does not exist, <codeph>template1</codeph> will be used.</pd>
          </plentry></parml></sectiondiv></section><section id="section6"><title>Notes</title>
            <p><codeph>reindexdb</codeph> causes locking of system catalog tables, which could
              affect currently running queries. To avoid disrupting ongoing business operations, schedule
              the <codeph>reindexb</codeph> operation during a period of low activity.</p>
            <p><codeph>reindexdb</codeph> might need to 
                connect several times to the master server, asking for a password each time. It is convenient to have
              a <codeph>~/.pgpass</codeph> file in such cases.</p>
          </section><section id="section7"><title>Examples</title><p>To reindex the database <codeph>mydb</codeph>:</p><codeblock>reindexdb mydb</codeblock><p>To reindex the table <codeph>foo</codeph> and the index <codeph>bar</codeph> in a database named
          <codeph>abcd</codeph>:</p><codeblock>reindexdb --table foo --index bar abcd</codeblock></section><section id="section8">
      <title>See Also</title>
      <p><ph otherprops="op-print"><codeph>REINDEX</codeph> in the <i>Greenplum Database Reference
            Guide</i></ph><ph><xref href="../../ref_guide/sql_commands/REINDEX.xml#topic1"
        /></ph></p>
    </section></body></topic>
